package com.itheima.controller;

import com.itheima.common.R;
import com.itheima.pojo.Type;
import com.itheima.service.CategoryService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;

/**
 * @author Envy
 */
@RestController
@RequestMapping(value = "/category",produces = "application/json;charset=utf-8")
public class CategoryController {
    @Resource
    private CategoryService categoryService;

    /**
     * 分类列表
     */
    @GetMapping("/list")
    public R<List<Type>> selectType() {
        List<Type> types = categoryService.selectType();
        if (types.size() != 0) {
            return R.success(types);
        }
        return R.error("暂无数据");
    }
}
